import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/Home.vue";
import first from "../views/first.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "Home1",
    component: ()=> import('../views/home1.vue')
  },
  {
    path: "/home",
    name: "Home",
    component: Home,
  },
  {
    path: "/admin",
    name: "admin",
    component: ()=> import('../views/admin.vue'),
    children:[
      {
        path:"page1",
        name:"page1",
        component: ()=> import('../views/page1.vue'),
      },
      {
        path:"page2",
        name:"page2",
        component: ()=> import('../views/page2.vue'),
      }
    ]
  },
  {
    path: "/bmi",
    name: "bmi",
    component: () =>
      import( "../../../vue-cli/src/BMI.vue"),
  },
  {
    path: "/user/:id/:index",
    name: "user",
    component: () =>
      import( "../views/user.vue"),
  },
  {
    path: "/article/:id",
    name: "article",
    component: () =>
      import( "../views/acticle.vue"),
  },
  {
    path: "/chacao",
    name: "chacao",
    component: () =>
      import( "../views/chacao.vue"),
  },
  {
    path: "/m",
    name: "m",
    component: () =>
      import( "../views/m.vue"),
    children:[
      {
        path: "",
        name: "home",
        component: () =>import("../views/m/home"),
      },
      {
        path: "/fenlei",
        name: "fenlei",
        component: () =>import("../views/m/fenlei"),
      },
      {
        path: "cart",
        name: "cart",
        component: () =>import("../views/m/cart"),
      },
      {
        path: "/mine",
        name: "mine",
        component: () =>import("../views/m/mine"),
      },
    ]
  },
  
  {
    path: "/first",
    name:"first",
    component: first
  },
 
  {
    path:'/second',
    redirect:{
      name:"first"
    },
  },
  {
    path:'*',
    name:'notfound',
    component:()=>import('../views/age.vue')
  }

  
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});



export default router;
router.beforeEach((to, from, next) => {
  // console.log("to",to)
  // console.log("from",from)
  
  next()
})